import { ElMessage, dayjs } from 'element-plus';
import relativeTime from 'dayjs/plugin/relativeTime'
import 'dayjs/locale/zh-cn'
dayjs.extend(relativeTime)
dayjs.locale('zh-cn')

//复制文本
export const forestCopyText = (text) => {
    const textarea = document.createElement('textarea');
    textarea.value = text;
    document.body.appendChild(textarea);
    textarea.select();
    document.execCommand('copy');
    document.body.removeChild(textarea);
    ElMessage.success(`${text} 复制成功`)
}

//相对时间
export function relativeTimeFormater(time) {
    return dayjs().to(dayjs(time)) // 31 年后
}